package com.garen.sys.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.garen.common.BaseAction;
import com.garen.common.MsgBean;
import com.garen.common.PageBean;
import com.garen.sys.biz.IFireUserGpsBiz;
import com.garen.sys.entity.FireUser;
import com.garen.sys.entity.FireUserGps;
import com.garen.sys.filter.SysFilter;


@Controller
@RequestMapping("/sys")
public final class FireUserGpsAction extends BaseAction{

	@Autowired
	private IFireUserGpsBiz iFireUserGpsBiz;

	@RequestMapping("/fireusergps/json") 
	public ModelAndView json(PageBean<FireUserGps> pb,FireUserGps fireUserGps) {
		iFireUserGpsBiz.getFireUserGpsList(pb,fireUserGps);
		return Json(pb);
	}

	@RequestMapping("/fireusergps/boxJson") 
	public ModelAndView boxJson(FireUserGps fireUserGps) {
		return Json(iFireUserGpsBiz.getFireUserGpsList(fireUserGps));
	}

	@RequestMapping("/fireusergps/edit") 
	public ModelAndView edit(ModelAndView mav,FireUserGps fireUserGps) {
		mav.setViewName("sys/FireUserGpsEdit");
		if(fireUserGps.getGpsId() != null){
			fireUserGps=iFireUserGpsBiz.getFireUserGps(fireUserGps);
		}
		mav.addObject("fireUserGps",fireUserGps);
		return mav;
	}

	@RequestMapping("/fireusergps/save") 
	public ModelAndView save(FireUserGps fireUserGps) {
		MsgBean mbean = SysFilter.getMsgBean(0, "保存成功 !");
		if(fireUserGps.getLat() == null ||
				fireUserGps.getLon() == null){
			mbean.setRetInfo(-1, "参数不正确!");
		}else {
			FireUser user = getSessionUser();
			fireUserGps.setUserId(user.getUserId());
			iFireUserGpsBiz.saveFireUserGps(mbean,fireUserGps);
		}
		return Json(mbean);
	}

	@RequestMapping("/fireusergps/del") 
	public ModelAndView del(FireUserGps fireUserGps) {
		MsgBean mbean = SysFilter.getMsgBean(0, "删除成功 !");
		iFireUserGpsBiz.delFireUserGps(mbean,fireUserGps);
		return Json(mbean);
	}

}
